package com.leyou.config;

import com.leyou.interceptor.AppTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * SpringMVC配置类
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer{
    @Autowired
    private AppTokenInterceptor appTokenInterceptor;

    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * addPathPatterns(): 配置拦截器拦截路径
         * excludePathPatterns()： 配置拦截器排除路径
         */
        registry.addInterceptor(appTokenInterceptor).addPathPatterns("/**");

    }
}
